import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home'
import Total from "@/views/Home/Total"
import CommAdd from "@/views/Home/CommAdd"
import CommList from "@/views/Home/CommList"
import CommLabel from "@/views/Home/CommLabel"
import NoDefined from "@/views/Home/404"
import Login from "@/views/Login"
import Register from '@/views/Register'
import AddContent from "@/views/Home/CommAdd/AddContent"
import EidtContent from "@/views/Home/CommAdd/EidtContent"

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home,
        //路由重定向
        redirect:"Login",
        children:[
            {
                //统计
                path:"/total",
                name:"Total",
                component: Total
            },{
                //添加商品 动态路由
                path:"/commAdd:addId",
                name:"CommAdd",
                component: CommAdd,
            },{
                //商品列表
                path:'/commList',
                name:'CommList',
                component: CommList
            },{
                //商品标签
                path:'/commLabel',
                name:'CommLabel',
                component: CommLabel
            }
        ]
    },{
        //登录页
        path:"/login",
        name:'Login',
        component: Login
    },{
        //注册
        path:'/register',
        name:'Register',
        component: Register
    },{
        //404
        path:"*",
        name: 'NoDefined',
        component: NoDefined
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})

export default router